<template>
	<div>
		<!--<van-nav-bar :title="$t('message.global.ForgotPassword')" left-text="" right-text="" left-arrow @click-left="onClickLeft" />-->

		<van-cell-group style="width: 100%;text-align: center;margin-top: 30px;">
			<van-field v-model="newpassword" :placeholder="$t('message.global.passwordMelogincn')" />
			<p class="registercen">{{$t('message.global.passwordLength')}}</p>
			<van-field v-model="againpassword" :placeholder="$t('message.global.confirmLogin')" />
		</van-cell-group>
		<div style="width: 100%;text-align: center;margin-top: 80px;">

			<van-button @click='register()' style="width: 18.59375rem;background: rgba(1, 205, 152, 1);border: none;color: #fff;text-align: center;font-size: 1rem;" type="default">
				<!-- 下一步 -->
				{{$t('message.global.nextStep')}}
			</van-button>

		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				newpassword: '',
				againpassword: ''
			}
		},
		mounted() {
			console.log(this.$route.query)
		},
		methods: {
			onClickLeft() {
				this.$router.go(-1)
			},
			//			完成
			register() {
				if(this.newpassword == '' || this.newpassword === null || this.newpassword === undefined) {
					
					this.$toast({
                      message: this.$t('message.global.loginpassword'),
                     duration: 800 
                  })
				} else if(this.againpassword == '' || this.againpassword === null || this.againpassword === undefined) {
					
					this.$toast({
                      message: this.$t('message.global.loginpassword'),
                     duration: 800 
                  })
				} else if(this.againpassword === this.newpassword) {
					
					var patrn=/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/
					if (patrn.exec(this.againpassword)){
						this.$router.push({
							path: '/paymentcode/',
							query: {
								'referrer_uid': this.$route.query.referrer_uid,
								'pin_code': this.$route.query.pin_code,
								"mobile": this.$route.query.mobile,
								"password": this.newpassword
							}
						})
					}else{
						
						this.$toast({
                      message: this.$t('message.global.IncorrectPasswordFormat'),
                     duration: 800 
                  })
					}
					

				}else{
					this.$toast({
                      message: this.$t('message.global.passwordsAreDifferent'),
                     duration: 800 
                  })
					
				}

			}
		}
	}
</script>

<style scoped>
	.van-nav-bar {
		/*background: linear-gradient(blue, pink);*/
		background: linear-gradient(to right, #FF6348,#ff755d,  #FFC267)
	}
	.registercen{
		padding: 0rem 1rem;
		text-align: left;
		line-height: 1.875rem;
		font-size: 0.8125rem;
		color: rgba(166, 166, 166, 1);
	}
	.van-nav-bar__title {
		color: #fff;
	}
	.van-nav-bar .van-icon{
		color: #fff;
	}
</style>